import { fileURLToPath, URL } from "node:url";

import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '');

  return {
    plugins: [vue()],
    resolve: {
      alias: {
        "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
    },
    server: {
      port: 8081,
      host: env.VITE_APP_HOST,
      proxy: {
        '/api': {
          target: "http://" + env.VITE_APP_HOST + ":" + env.VITE_APP_API_PORT,
          changeOrigin: true,
        }
      },
    },
    base: "/",
    build: {
      chunkSizeWarningLimit: 3000,
    },
  };
});
